-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.toThrowError() #1301
.toThrowError() #1301
Conversation
describe('.toThrowError()', () => { | ||
describe('strings', () => { | ||
it('passes', () => { | ||
expect(() => { throw new Error('lol'); }).toThrowError('lol'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think lol
and lmao
are pretty awkward in tests. Can we fall back to banana
and apple
like jest-haste-map
does? :)
Looks good except for a few minor nits and those clowny strings in your tests :P |
@@ -78,9 +84,27 @@ const addMatchers = (matchersObj: MatchersObject): void => { | |||
Object.assign(global[GLOBAL_MATCHERS_OBJECT_SYMBOL], matchersObj); | |||
}; | |||
|
|||
const _validateResult = result => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using an arrow function here also causes an unnecassary .bind(this)
call. It'd be more efficient to use a normal function here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true. i'd be interested in benchmarking this stuff. I don't think it's going to affect the overall performance that much though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There aren't any unnecessary bind calls because this is run in node 4 without compiling arrow functions to functions. Also babel doesn't bind if there is no this access iirc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:themoreyouknow: I benchmarked the arrow vs regular function in JavaScriptCore and to my surprise, arrow functions are natively faster.
normal x 53,987,644 ops/sec ±3.50% (44 runs sampled)
arrow x 57,679,587 ops/sec ±3.08% (58 runs sampled)
@@ -75,6 +90,9 @@ const stringify = (obj: any): string => { | |||
}); | |||
}; | |||
|
|||
// highlight an object | |||
const h = (obj: any) => chalk.cyan.bold(stringify(obj)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call this highlight? Then we don't need the comment and people will understand what h
means.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
No description provided.